package br.mia.unifor.olio.artifact;

import java.util.ArrayList;
import java.util.List;

import br.mia.unifor.crawler.executer.artifact.Application;
import br.mia.unifor.crawler.executer.artifact.VirtualMachine;

public class OlioApplication implements Application {
	private VirtualMachine database;
	private VirtualMachine driver;

	private List<VirtualMachine> web;

	public VirtualMachine getDatabase() {
		return database;
	}

	public void setDatabase(VirtualMachine mysql) {
		this.database = mysql;
	}

	public VirtualMachine getDriver() {
		return driver;
	}

	public void setDriver(VirtualMachine driver) {
		this.driver = driver;
	}

	public List<VirtualMachine> getWeb() {
		return web;
	}

	public void setWeb(List<VirtualMachine> web) {
		this.web = web;
	}
	
	public boolean setUp() {
		return true;
	}

	public boolean teardown() {
		return true;
	}

	public List<VirtualMachine> getVirtualMachines() {
		List<VirtualMachine> retorno = new ArrayList<VirtualMachine>();
		retorno.add(database);
		retorno.add(driver);

		for (VirtualMachine instance : web) {
			retorno.add(instance);
		}

		return retorno;
	}

	@Override
	public String getDescription() {
		String retorno = "";
		for (VirtualMachine instance : getVirtualMachines()) {
			retorno += instance.getName()+" ("+ instance.getType().getProviderProfile()+ ") | ";
		}
		return retorno;
	}
}
